#!/usr/bin/env node

const http = require('http');
//qs = require('querystring');
//url:http://localhost:8080/add?x=2&y=3

http.createServer((req,res)=>{
  console.log(`${req.method} ${req.url} HTTP/${req.httpVersion}`);
  if(req.method !== 'POST'){
    res.end('ok');
    return;
  }
  let data = '';
  req.on('data',(chunck)=>data += chunck);
  req.on('end',()=>{
    //console.log(qs.parse(data));
    console.log(data);
    res.end('ok');
  });
  //req.pipe(process.stdout);
  //res.end('ok');
}).listen(8000);


